<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/stylez.css" />
	<script src="<?php echo base_url(); ?>assets/js/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>assets/js/jheader-area.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>assets/js/jquery-css-transform.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>assets/js/sun-rays.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>assets/js/jquery-animate-css-rotate-scale.js" type="text/javascript"></script>

	<title><?php echo $title; ?></title>

	<script type = "text/javascript">

		$(document).ready(function(){
			$('.error').hide();
			$('#add-testimonial-form').submit(function(){

				var testi_message = $('#testi-message').attr("value");
				var captcha = $('#captcha').attr("value");
				var error = true;

				if(testi_message == ""){
					error = false;
					$('.error').html("Please fill up your testimonial.").fadeIn().delay(1000).fadeOut();
				}
				else{
					if(captcha == ""){
					error = false;
					$('.error').html("Please fill up captcha.").fadeIn().delay(1000).fadeOut();
					}
					else{
						var $captcha = $('#captcha').val();
						var path = $('#hidden-captcha').attr("value");
						//alert("ok");
							$.ajax({
							url:path,
							type:'post',
							data:'captcha='+$captcha,
							success:function(data) {
								if(data=="same"){
									//alert("ok");
									error = true;

									var form_data = $('#add-testimonial-form').serialize();
									var path1 = $('#hidden').attr("value");

									$.ajax({
										url: path1,
										data: form_data,
										type : 'POST',

										 success: function(data){
											$('.error').html("Sakto.").fadeIn().delay(1000).fadeOut(1000, function(){
												$('#testi-wrap').prepend('<li><div id = "testi-info"><p>'+$('#testi-message').val()+'</p></div><div id = "testi-user"><p class = "testi-uname"></p></div></li>', function(){
													$('#testi-message').val('');
												});
											});

										},
										 complete: function(){
											$('#captcha').val('');
										},

									});

								}else{
									error = false;
									$('.error').html("Incorrect captcha.").fadeIn().delay(1000).fadeOut();
								}
							}
						});

					}
				}



				return false;
			});


	$('#contact_message').val("Your Message");

	$("#contact-wrap input, #contact-wrap textarea").focus(function(){ $(this).val('');

	 switch($(this).attr('id')){

	     case 'contact_name': $(this).focusout(function(){
	     	if($(this).val()=='') $(this).val('Your Name');
	     }); break;

	     case 'contact_email': $(this).focusout(function(){
	     	 if($(this).val()=='') $(this).val('Your Email');
	     }); break;

	     case 'contact_subject': $(this).focusout(function(){
	     	 if($(this).val()=='') $(this).val('Your Subject');
	     }); break;

	     case 'contact_message': $(this).focusout(function(){
	     	 if($(this).val()=='') $(this).val('Your Message');
	     }); break;
	 }
	});


	$('#contact-form').submit(function(){

		var contact_name = $('#contact_name').attr("value");
		var contact_email = $('#contact_email').attr("value");
		var contact_subject = $('#contact_subject').attr("value");
		var contact_message = $('#contact_message').attr("value");
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

		var captcha = $('#captcha').attr("value");
		var error = true;

		if(contact_name == "Your Name"){
			error = false;
			$('.error').html("Please fill up your Name.").fadeIn().delay(1000).fadeOut();
		}
		else{
			if(contact_email == "Your Email"){
				error = false;
				$('.error').html("Please fill up your Email.").fadeIn().delay(1000).fadeOut();
			}
			else if(!(emailReg.test(contact_email)) ){
				error = false;
				$('.error').html("Invalid Email format.").fadeIn().delay(1000).fadeOut();
			}
			else{
				if(contact_subject == "Your Subject"){
					error = false;
					$('.error').html("Please fill up your Subject.").fadeIn().delay(1000).fadeOut();
				}
				else{
					if(contact_message == "Your Message"){
						error = false;
						$('.error').html("Please fill up your Message.").fadeIn().delay(1000).fadeOut();
					}
					else{
						if(captcha == ""){
							error = false;
							$('.error').html("Please fill up captcha.").fadeIn().delay(1000).fadeOut();
						}
						else{
							var $captcha = $('#captcha').val();
							var path = $('#hidden-captcha').attr("value");
							//alert("ok");

							$.ajax({
								url:path,
								type:'post',
								data:'captcha='+$captcha,
								success:function(data) {
									if(data=="same"){
										$('.error').html("ok.").fadeIn().delay(1000).fadeOut();
										error = true;
									}
									else{
										$('.error').html("no.").fadeIn().delay(1000).fadeOut();
										error = true;
									}
								}
							});
						}
					}
				}
			}
		}

		return false;
	});

});
	</script>

</head>
<?php
$records = myuser_helper::getUserData();
?>
<body>
	<div id = "bg-container">
		<div id = "sun-rays" class = "sun-rays">
		</div>
	</div>

	<div id = "wrapper">
		<header>
			<div id = "flash-area">
				<embed src="<?php echo base_url(); ?>assets/images/hearttree-profile.swf" width="212" height="180" type="application/x-shockwave-flash" wmode="transparent" menu="false" />
			</div>
			<div id = "menu-area">
				<ul id = "user-menu">
					<a href = "<?php echo base_url();?>" title = "Home"><li class = "user-home"></li></a>
					<a href = ""><li class = "user-profile"></li></a>
					<a href = "<?php echo base_url();?>testimonial"><li class = "user-testi"></li></a>
					<a href = ""><li class = "user-faq"></li></a>
					<a href = "<?php echo base_url();?>contact/"><li class = "user-contct"></li></a>
				</ul>
			</div>


			<?php if (isset($_SESSION['is_logged_in']) && $_SESSION['is_logged_in']) : ?>

				<div id = "account-area">
					<div id = "account-wrap">
						<div id = "accountz">
							<div class = "profile-pic">
								<img style="width:30px;height:27px;" src = "<?php echo !empty($records->picture) ? base_url().'assets/images'.$records->picture : base_url().'assets/images/default.png';?>" /></div>

							<h2><?php echo $records->firstname; ?></h2>

							<span id = "arrow-down"><img src = "<?php echo base_url(); ?>assets/images/arrow-down.png" /></a></span>
							<div id = "account-list">
								<ul>
									<li><a href = "">My Account</a></li>
									<li><a href = "">Edit Settings</a></li>
									<li><a href = "">Help</a></li>
									<li><a href = "<?php echo base_url(); ?>profile/logout">Logout</a></li>
								</ul>
							</div>
						</div>
					</div>
				</div>
			<?php else: ?>

			<?php endif; ?>


		</header>

		<div id = "wrap">